package com.qitai.standard.listener;

import java.lang.reflect.Field;

public class ReflectionUtils {

    public static void setEmptyStringsToNull(Object object) throws IllegalAccessException {
        Class<?> clazz = object.getClass();
        for (Field field : clazz.getDeclaredFields()) {
            field.setAccessible(true); // 设置为可访问，以便可以访问私有字段

            try {
                Object value = field.get(object);
                if (value instanceof String && "<空>".equals(value)) {
                    field.set(object, null);
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }
}